/*
 * Vertex.java
 *
 * Created on September 14, 2006, 2:36 PM
 *
 * (C) 2006 R. Alexander Milowski
 */

package com.smallx.xproc.compiler.graph;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import org.infoset.xml.Name;
import org.infoset.xml.NamespaceScope;

/**
 *
 * @author alex
 */
public class Vertex extends HashSet<Edge> {

   Name type;
   Name name;
   String id;
   String label;
   Map<Name,String> parameters;
   String expression;
   NamespaceScope scope;
   NamespaceScope expScope;
   
   /** Creates a new instance of Vertex */
   public Vertex(String id) {
      this(id,id);
   }
   /** Creates a new instance of Vertex */
   public Vertex(String id,String label) {
      this.id = id;
      this.label = label;
      this.type = null;
      this.name = null;
      this.parameters = null;
      this.scope = null;
   }
   
   public Name getName() {
      return name;
   }
   
   public Name getType() {
      return type;
   }
   
   public NamespaceScope getNamespaceScope() {
      return scope;
   }
   
   public String getExpression() {
      return expression;
   }
   
   public NamespaceScope getExpressionNamespaceScope() {
      return expScope;
   }
   
   
   public void setName(Name name)
   {
      this.name = name;;
   }
   
   public void setType(Name type)
   {
      this.type = type;
   }
   
   public void setNamespaceScope(NamespaceScope scope)
   {
      this.scope = scope;
   }
   
   public void setExpression(String value,NamespaceScope expScope) {
      this.expression = value;
      this.expScope = expScope;
      if (expression!=null) {
         this.label += " select="+value;
      }
   }
   
   public String getId() {
      return id;
   }
   
   public String getLabel() {
      return label;
   }
   
   public boolean hasParameters() {
      return parameters!=null;
   }
   
   public Map<Name,String> getParameters() {
      if (parameters==null) {
         parameters = new HashMap<Name,String>();
      }
      return parameters;
   }
   
   public int hashCode() {
      return id.hashCode();
   }
   
}
